#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
    ,_n(0)
{
    ui->setupUi(this);
    mybutton = new QPushButton(this);
    mybutton->setText("a");
    mybutton->move(200,200);
    connect(mybutton,&QPushButton::clicked,this,&Widget::handls);
    connect(this,&Widget::mysignal,this,&Widget::handls);
    //disconnect解绑槽函数
    //lambda表达是可作为槽函数
    //mybutton->setEnabled(false);//禁用
    //mybutton->geometry();

}

Widget::~Widget()
{
    delete ui;
}

void Widget::handls()
{


    if(mybutton->text() == "a")mybutton->setText("b");
    else mybutton->setText("a");
    _n++;

    if(_n == 5) this->setWindowTitle("我是标题");
    else if(_n == 10) Widget::close();
}


void Widget::on_pushButton_clicked()
{
    emit mysignal();//发射信号
    if(_n == 5) this->setWindowTitle("我是标题");
    else if(_n == 7) ui->pushButton->setText("qt");
}
